package canhcua.dh;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.net.MailTo;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class Result extends ListActivity {
	private final String arr[]={"Câu 1:","Câu 2:","Câu 3:","Câu 4:","Câu 5:","Câu 6:","Câu 6:","Câu 6:","Câu 6:","Câu 6:"};
	ListView lv1,list_rs;
	Dialog dialog;
	TextView txt_message;
	Button dialogOk;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.result_exam);
		setTitle("KẾT QUẢ");
		lv1=(ListView)findViewById(android.R.id.list);
		lv1.setAdapter(new ArrayAdapter<String>(this, R.layout.list_exam,R.id.txt_cauhoi,arr));
		lv1.setOnItemClickListener(list_click);
		txt_message=(TextView)findViewById(R.id.txt_mesage);
		dialogOk=(Button)findViewById(R.id.bt_dialog_ok);
		
		
	}
	OnItemClickListener list_click=new OnItemClickListener() {

		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			// TODO Auto-generated method stub
			
			Toast.makeText(getApplicationContext(), "Hello man!", Toast.LENGTH_SHORT).show();
			Alert(arg2);
		}
	};
	
	// alert dialog
	
	public void Alert(int i)
	{
		//txt_message.setText("["+i+"] Because: You are crayzier!");
		dialog = new Dialog(this);
		dialog.setContentView(R.layout.dialog);
		dialog.setTitle("Lời giải");
	/*	dialogOk.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				dialog.dismiss();
			}
		}); */
		dialog.show();
	}
	public void homeclick(View v)
	{
		Intent i=new Intent(this,CanhcuadhActivity.class);
		this.startActivity(i);
		this.finish();
	}
	public void data(View w)
	{
		setContentView(R.layout.sql);
	}
}
